const Joi = require("joi");

// required() 为必填项，用户名可以用中英日韩最大长度为10，密码最少6位1大写1小写
const nickname = Joi.string().pattern(/^[A-Za-z0-9\u4E00-\u9FA5\u3040-\u309F\u30A0-\u30FF\u31F0-\u31FF\uAC00-\uD7A3]+$/).min(1).max(12).required();
const password = Joi.string().pattern(/^\S*(?=\S{6,18})(?=\S*[A-Z])(?=\S*[a-z])\S*$/).required();
const email = Joi.string().email().required();
const gender = Joi.number().integer().valid(0, 1, 2);

// 更新用户基本信息验证规则
exports.update_Schema = {
	body: {
		nickname,
		email,
		gender
	}
};

// 验证规则对象更新密码
exports.reset_schema = {
	body: {
		oldPwd: password,
		newPwd: Joi.not(Joi.ref("oldPwd")).concat(password)
	}
};